/**
 * <copyright>
 * </copyright>
 *

 */
package org.xtext.example.cr.cR.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.xtext.example.cr.cR.ArrayDec;
import org.xtext.example.cr.cR.CRPackage;
import org.xtext.example.cr.cR.PrimitiveDec;
import org.xtext.example.cr.cR.VarDec;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Var Dec</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.example.cr.cR.impl.VarDecImpl#getPrimitiveDec <em>Primitive Dec</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.VarDecImpl#getArrayDec <em>Array Dec</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class VarDecImpl extends MinimalEObjectImpl.Container implements VarDec
{
  /**
   * The cached value of the '{@link #getPrimitiveDec() <em>Primitive Dec</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPrimitiveDec()
   * @generated
   * @ordered
   */
  protected PrimitiveDec primitiveDec;

  /**
   * The cached value of the '{@link #getArrayDec() <em>Array Dec</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getArrayDec()
   * @generated
   * @ordered
   */
  protected ArrayDec arrayDec;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected VarDecImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return CRPackage.Literals.VAR_DEC;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public PrimitiveDec getPrimitiveDec()
  {
    return primitiveDec;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetPrimitiveDec(PrimitiveDec newPrimitiveDec, NotificationChain msgs)
  {
    PrimitiveDec oldPrimitiveDec = primitiveDec;
    primitiveDec = newPrimitiveDec;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRPackage.VAR_DEC__PRIMITIVE_DEC, oldPrimitiveDec, newPrimitiveDec);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setPrimitiveDec(PrimitiveDec newPrimitiveDec)
  {
    if (newPrimitiveDec != primitiveDec)
    {
      NotificationChain msgs = null;
      if (primitiveDec != null)
        msgs = ((InternalEObject)primitiveDec).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRPackage.VAR_DEC__PRIMITIVE_DEC, null, msgs);
      if (newPrimitiveDec != null)
        msgs = ((InternalEObject)newPrimitiveDec).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRPackage.VAR_DEC__PRIMITIVE_DEC, null, msgs);
      msgs = basicSetPrimitiveDec(newPrimitiveDec, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.VAR_DEC__PRIMITIVE_DEC, newPrimitiveDec, newPrimitiveDec));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ArrayDec getArrayDec()
  {
    return arrayDec;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetArrayDec(ArrayDec newArrayDec, NotificationChain msgs)
  {
    ArrayDec oldArrayDec = arrayDec;
    arrayDec = newArrayDec;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRPackage.VAR_DEC__ARRAY_DEC, oldArrayDec, newArrayDec);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setArrayDec(ArrayDec newArrayDec)
  {
    if (newArrayDec != arrayDec)
    {
      NotificationChain msgs = null;
      if (arrayDec != null)
        msgs = ((InternalEObject)arrayDec).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRPackage.VAR_DEC__ARRAY_DEC, null, msgs);
      if (newArrayDec != null)
        msgs = ((InternalEObject)newArrayDec).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRPackage.VAR_DEC__ARRAY_DEC, null, msgs);
      msgs = basicSetArrayDec(newArrayDec, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.VAR_DEC__ARRAY_DEC, newArrayDec, newArrayDec));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case CRPackage.VAR_DEC__PRIMITIVE_DEC:
        return basicSetPrimitiveDec(null, msgs);
      case CRPackage.VAR_DEC__ARRAY_DEC:
        return basicSetArrayDec(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case CRPackage.VAR_DEC__PRIMITIVE_DEC:
        return getPrimitiveDec();
      case CRPackage.VAR_DEC__ARRAY_DEC:
        return getArrayDec();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case CRPackage.VAR_DEC__PRIMITIVE_DEC:
        setPrimitiveDec((PrimitiveDec)newValue);
        return;
      case CRPackage.VAR_DEC__ARRAY_DEC:
        setArrayDec((ArrayDec)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case CRPackage.VAR_DEC__PRIMITIVE_DEC:
        setPrimitiveDec((PrimitiveDec)null);
        return;
      case CRPackage.VAR_DEC__ARRAY_DEC:
        setArrayDec((ArrayDec)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case CRPackage.VAR_DEC__PRIMITIVE_DEC:
        return primitiveDec != null;
      case CRPackage.VAR_DEC__ARRAY_DEC:
        return arrayDec != null;
    }
    return super.eIsSet(featureID);
  }

} //VarDecImpl
